package com.ruoyi.project.loan.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.project.loan.domain.LoanContract;
import com.ruoyi.project.loan.mapper.LoanContractMapper;
import com.ruoyi.project.loan.service.ILoanContractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 贷款合同Service业务层处理
 *
 * @author ruoyi
 * @date 2025-11-11
 */
@Service
public class LoanContractServiceImpl implements ILoanContractService {
    @Autowired
    private LoanContractMapper loanContractMapper;

    /**
     * 查询贷款合同
     *
     * @param contractId 贷款合同主键
     * @return 贷款合同
     */
    @Override
    public LoanContract selectLoanContractByContractId(Long contractId) {
        return loanContractMapper.selectLoanContractByContractId(contractId);
    }

    /**
     * 查询贷款合同列表
     *
     * @param loanContract 贷款合同
     * @return 贷款合同
     */
    @Override
    public List<LoanContract> selectLoanContractList(LoanContract loanContract) {
        return loanContractMapper.selectLoanContractList(loanContract);
    }

    /**
     * 新增贷款合同
     *
     * @param loanContract 贷款合同
     * @return 结果
     */
    @Override
    public int insertLoanContract(LoanContract loanContract) {
        loanContract.setCreateTime(DateUtils.getNowDate());
        return loanContractMapper.insertLoanContract(loanContract);
    }

    /**
     * 修改贷款合同
     *
     * @param loanContract 贷款合同
     * @return 结果
     */
    @Override
    public int updateLoanContract(LoanContract loanContract) {
        loanContract.setUpdateTime(DateUtils.getNowDate());
        return loanContractMapper.updateLoanContract(loanContract);
    }

    /**
     * 批量删除贷款合同
     *
     * @param contractIds 需要删除的贷款合同主键
     * @return 结果
     */
    @Override
    public int deleteLoanContractByContractIds(Long[] contractIds) {
        return loanContractMapper.deleteLoanContractByContractIds(contractIds);
    }

    /**
     * 删除贷款合同信息
     *
     * @param contractId 贷款合同主键
     * @return 结果
     */
    @Override
    public int deleteLoanContractByContractId(Long contractId) {
        return loanContractMapper.deleteLoanContractByContractId(contractId);
    }
}
